#include "StdAfx.h"
#include "CSubCon.h"
#include "CSubConPainter.h"






CSubConPainter::CSubConPainter(void):CContainerPainter()
{

}

void CSubConPainter::Paint(CDC* pDc, CContainer* pContainer, CRect& rc)
{
	int nCount = pContainer->m_vecControls.size();

	

	CRect validRc=((CSubCon*)pContainer)->GetValidRect();
	CRect rc1(0,0,((CSubCon*)pContainer)->GetRect().Width(),((CSubCon*)pContainer)->GetRect().Height());
	CMemoryDC *pMemDC = new CMemoryDC(pDc->m_hDC,rc1);
	for(int i=0; i < nCount; i++)
	{
		
		 pContainer->m_vecControls.at(i)->Paint(pMemDC);
	}
	CRect rcClient=((CSubCon*)pContainer)->GetRect();
	rcClient.bottom=rcClient.top+validRc.Height();
	rcClient.right=rcClient.left+validRc.Width();

	pDc->BitBlt(rcClient.left,rcClient.top,rcClient.Width(),rcClient.Height(),pMemDC->m_hDC,
		0,validRc.top,SRCCOPY);
    pMemDC->SetAutoDraw(false);
	delete  pMemDC;
	pMemDC=NULL;
}